﻿using AnQinFrameWorkAPI.Entity.SystemCore.DTO.MenuBotton;
using AnQinFrameWorkAPI.Entity.SystemCore.View.MenuButton;
using AnQinFrameWorkAPI.Service.SystemCore;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.SystemCore;

/// <summary>
///     菜单按钮API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "SystemCore")]
public class MenuButtonController : ControllerBase
{
    //业务接口
    private readonly MenuButtonService _menuButtonService;

    //构造注入
    public MenuButtonController(MenuButtonService menuButtonService)
    {
        _menuButtonService = menuButtonService;
    }

    /// <summary>
    ///     获取菜单按钮列表
    /// </summary>
    [ProducesResponseType(typeof(MenuButtonView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetMenuButtonList([FromQuery] MenuButtonSearchDTO menuButtonSearchDTO)
    {
        var response = await _menuButtonService.GetMenuButtonList(menuButtonSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增菜单按钮
    /// </summary>
    /// <params name="menuButtonAddDTO"></params>
    [HttpPost]
    public async Task<IActionResult> AddMenuButton([FromBody] MenuButtonAddDTO menuButtonAddDTO)
    {
        var response = await _menuButtonService.AddMenuButton(menuButtonAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     编辑菜单按钮
    /// </summary>
    /// <params name="menuButtonUpdateDTO"></params>
    [HttpPut]
    public async Task<IActionResult> PutMenuButton([FromBody] MenuButtonUpdateDTO menuButtonUpdateDTO)
    {
        var response = await _menuButtonService.PutMenuButton(menuButtonUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除菜单按钮
    /// </summary>
    [HttpDelete]
    public async Task<IActionResult> DeleteMenuButton([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _menuButtonService.DeleteMenuButton(deleteDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     批量删除菜单按钮
    /// </summary>
    [HttpDelete("DeleteMulti")]
    public async Task<IActionResult> DeleteArrayMenuButton([FromBody] IdArrayDTO idArrayDTO)
    {
        var response = await _menuButtonService.DeleteArrayMenuButton(idArrayDTO);
        return StatusCode(response.Status, response);
    }
}